import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import { resolve } from 'path'
import vue from '@vitejs/plugin-vue'
import sassPlugin from "vite-plugin-sass"
// import webWorkerLoader from 'rollup-plugin-web-worker-loader';
import sass from 'vite-plugin-sass';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
// 按需导入导致onMounted警告?
// /usr/share/nginx/html
// @wangeditor/editor

// https://vitejs.dev/config/

export default defineConfig({
  plugins: [
    vue(),

    AutoImport({
      imports:['vue','vue-router'],
      // resolvers: [ElementPlusResolver()],
    }),
  ],
  // css:{
  //   preprocessorOptions: {
  //     scss: {

  //     }
  //   }
  // },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server:{

    proxy:{

      '/servlet/my':{
        target:'http://localhost:26001',
        rewrite:(path) => path.replace(/^\/servlet\/my/, ""),
      },
      '/servlet':{
        // target:'https://api-pro.yunxuebao.com',

        // target:'https://api-test.yunxuebao.com',
        // target:'http://localhost:8082',
        // target:'http://192.168.0.106:26001',
        // target:'http://luokaixin.a1.luyouxia.net:21849',
        target:'http://localhost:8090',

        // target:"http://www.zzwx.cn:8082",
        // target:'http://192.168.0.116:26001',
        // changeOrigin:true,
        // rewrite:(path) => path.replace(/^\/servlet/, ""),
      },
    },   //27107  以zzw启动elasticsearch
    // https:true
  },
  client:{
    // overlay: {
    //   // 默认为 true
    //   warnings: false,
    //   // 默认为 true
    //   errors: false,
    // },
  },
  build: {
    rollupOptions: {
      input: {
        main: resolve(__dirname, 'index.html'),
        other: resolve(__dirname, 'nested/other.html'),
      }
    }
  }
})
